<?php
// +----------------------------------------------------------------------
// | quanli team
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.fistforward.com/ All rights reserved.
// +----------------------------------------------------------------------
// | create by allen.qiang
// +----------------------------------------------------------------------


/**
 * seo设置
 * @package  htdocs
 * @subpackage  quanliadmin
 * @create by allen.qiang
 */
quanli_require('module/base/goodsHandler.class.php');

class pa_seo {

    public function execute() {
        global $G_PGLOB ;
        if (isset($_REQUEST['operFlg'])) {

            switch($_REQUEST['operFlg']) {

                case 1: //客户信息列表
                    $this->seoList();
                    break;

                case 2: //添加客户信息
                    $this->seoAdd();
                    break;

                case 3: //编辑客户信息
                    $this->seoEdit();
                    break;

                default:
                    $G_PGLOB->smarty->assign('msg', '参数错误，请审核后再操作');
                    $G_PGLOB->smarty->display('comm/error.tpl');

            }
        }
    }

    /**
     * seo列表
     *
     */
    private function seoList() {

        global $G_PGLOB;

        $G_PGLOB->smarty->display('system/seoList.tpl');

    }

    /**
     * 添加seo
     */
    private function seoAdd () {

        global $G_PGLOB;

        //商品分类下拉菜单
        $goodsHandler = new goodsHandler( $G_PGLOB->DBCA ) ;
        $result_data  = $goodsHandler->goodsCategoryList() ;
        $G_PGLOB->smarty->assign_by_ref( 'categoryInfo' , $result_data );
        $categoryTpl = $G_PGLOB->smarty->fetch( 'goods/category.tpl' );

        $G_PGLOB->smarty->assign('categoryTpl', $categoryTpl);
        $G_PGLOB->smarty->assign('operFlg', 2);
        $G_PGLOB->smarty->display('system/seoAdd.tpl');

    }

    /**
     * 编辑seo
     */
    public function seoEdit() {

        global $G_PGLOB;

        if (!isset($_REQUEST['uid']) || !isset($_REQUEST['pageType']) || $_REQUEST['uid'] == '' || !is_numeric($_REQUEST['pageType']) ) {
            $G_PGLOB->smarty->assign('msg', '参数错误');
            $G_PGLOB->smarty->display('comm/error.tpl');
            die() ;
        }

        //查询客户信息
        $seo_obj = new entity('sys_seo');
        $seo_obj->uid = $_REQUEST['uid'];
        $seo_obj->pageType = $_REQUEST['pageType'];

        if( !$G_PGLOB->DBCA->fetch($seo_obj) ){
            $G_PGLOB->smarty->assign('msg', '没有找到信息');
            $G_PGLOB->smarty->display('comm/error.tpl');
            die() ;
        }

        //商品分类下拉菜单
        $goodsHandler = new goodsHandler( $G_PGLOB->DBCA ) ;
        $result_data  = $goodsHandler->goodsCategoryList() ;
        $G_PGLOB->smarty->assign_by_ref( 'categoryInfo' , $result_data );
        $categoryTpl = $G_PGLOB->smarty->fetch( 'goods/category.tpl' );

        if( $_REQUEST['pageType'] == 2 ){

            $seo_obj->bigCategoryID   = substr($seo_obj->uid,0,2);

            $seo_obj->midCategoryID   = substr($seo_obj->uid,2,3);

            $seo_obj->smallCategoryID = substr($seo_obj->uid,5);

        }

        $G_PGLOB->smarty->assign('categoryTpl', $categoryTpl);
        $G_PGLOB->smarty->assign('seo_obj' , $seo_obj);
        $G_PGLOB->smarty->assign('operFlg', 3);
        $G_PGLOB->smarty->display('system/seoAdd.tpl');

    }

}